using System;
using System.Collections.Generic;

using UnityEngine;

/// <summary>
/// Singleton class that stores and provides a library of possible names
/// </summary>
public class CharacterNameLibrary
{
	//Singleton instance of this class
	private static CharacterNameLibrary sInstance;

	//List of possible male first names
	private List<string> mMaleFirstNameList;

	//List of possible female first names
	private List<string> mFemaleFirstNameList;

	//List of possible last names
	private List<string> mLastNameList;

	/// <summary>
	/// Gets the singleton instance
	/// </summary>
	/// <value>The singleton instance.</value>
	public static CharacterNameLibrary Instance{
		get{
			if(sInstance == null){
				sInstance = new CharacterNameLibrary();
			}

			return sInstance;
		}
	}
		
	protected CharacterNameLibrary ()
	{
		mMaleFirstNameList = new List<string>();
		mFemaleFirstNameList = new List<string>();
		mLastNameList = new List<string>();

		SetHardCodedNames();
	}

	/// <summary>
	/// Generates a name for a character of a particular gender
	/// </summary>
	/// <param name="gender">Gender of the name to generate</param>
	/// <param name="firstName">First name.</param>
	/// <param name="lastName">Last name.</param>
	public void GenerateName(Gender gender, out string firstName, out string lastName){
		switch(gender){
		case Gender.Male:
			firstName = mMaleFirstNameList[UnityEngine.Random.Range(0, mMaleFirstNameList.Count)];
			break;
		case Gender.Female:
			firstName = mFemaleFirstNameList[UnityEngine.Random.Range(0, mFemaleFirstNameList.Count)];
			break;
		default:
			firstName = "";
			break;
		}

		lastName = mLastNameList[UnityEngine.Random.Range(0, mLastNameList.Count)];
	}

	//TESTING - Use a set of hard-coded names
	private void SetHardCodedNames(){
		//Set some male first names
		mMaleFirstNameList.Add("Aleksio");
		mMaleFirstNameList.Add("Alesandro");
		mMaleFirstNameList.Add("Aron");
		mMaleFirstNameList.Add("Brian");
		mMaleFirstNameList.Add("Dexter");
		mMaleFirstNameList.Add("Drew");
		mMaleFirstNameList.Add("Enrik");
		mMaleFirstNameList.Add("Fatass");
		mMaleFirstNameList.Add("Flavio");
		mMaleFirstNameList.Add("Gandalf");
		mMaleFirstNameList.Add("Luis");
		mMaleFirstNameList.Add("Mark");
		mMaleFirstNameList.Add("Mike");
		mMaleFirstNameList.Add("Naruto");
		mMaleFirstNameList.Add("Natsu");
		mMaleFirstNameList.Add("Noel");
		mMaleFirstNameList.Add("Ron");
		mMaleFirstNameList.Add("Sauron");

		//Set some female first names
		mFemaleFirstNameList.Add ("Allison");
		mFemaleFirstNameList.Add ("Bertha");
		mFemaleFirstNameList.Add ("Catherine");
		mFemaleFirstNameList.Add ("Cleopatra");
		mFemaleFirstNameList.Add ("Elise");
		mFemaleFirstNameList.Add ("Emma");
		mFemaleFirstNameList.Add ("Erza");
		mFemaleFirstNameList.Add ("Francine");
		mFemaleFirstNameList.Add ("Gertrude");
		mFemaleFirstNameList.Add ("Hobag");
		mFemaleFirstNameList.Add ("Julie");
		mFemaleFirstNameList.Add ("Louise");
		mFemaleFirstNameList.Add ("Lucy");
		mFemaleFirstNameList.Add ("Marie");
		mFemaleFirstNameList.Add ("Sandra");
		mFemaleFirstNameList.Add ("Sarah");
		mFemaleFirstNameList.Add ("Skankara");

		//Set some last names
		mLastNameList.Add ("Smith");
		mLastNameList.Add ("Jones");
		mLastNameList.Add ("Taylor");
		mLastNameList.Add ("Brown");
		mLastNameList.Add ("Williams");
		mLastNameList.Add ("Wilson");
		mLastNameList.Add ("Johnson");
		mLastNameList.Add ("Davies");
		mLastNameList.Add ("Robinson");
		mLastNameList.Add ("Wright");
		mLastNameList.Add ("Thompson");
		mLastNameList.Add ("Evans");
		mLastNameList.Add ("White");
		mLastNameList.Add ("White");
		mLastNameList.Add ("Roberts");
		mLastNameList.Add ("Hall");
		mLastNameList.Add ("Wood");
		mLastNameList.Add ("Clarke");
		mLastNameList.Add ("Green");
		mLastNameList.Add ("Lei");
		mLastNameList.Add ("Darmitz");
		mLastNameList.Add ("Andrade");
		mLastNameList.Add ("Cautillo");
		mLastNameList.Add ("Ruslim");

	}
	//END TESTING
}


